package com.awt.moudle;



import javax.swing.*;
import java.awt.*;

/**
 * @authoer zsj
 * @date 2023/4/15 15:31
 */
public class BasicComponentDemo {

    Frame frame = new Frame("基本组件");
    TextArea textArea = new TextArea(5, 20);

    Choice colorChoice = new Choice();

    CheckboxGroup che = new CheckboxGroup();
    Checkbox male = new Checkbox("男", true);
    Checkbox female = new Checkbox("女", false);


    Checkbox isMarried = new Checkbox("是否已婚?");


    TextField textField = new TextField(20);
    Button ok = new Button("确认");

    List color = new List(6, true);


    //初始化
    public void init() {
        Box hBox = Box.createHorizontalBox();
        Panel panel = new Panel();
        panel.add(textField);
        panel.add(ok);
        frame.add(panel, BorderLayout.SOUTH);

        Box cBox = Box.createHorizontalBox();
//        colorChoice.setSize(30,30);
        colorChoice.add("红色");
        colorChoice.add("蓝色");
        colorChoice.add("绿色");
        colorChoice.add("白色");
        cBox.add(colorChoice);
        cBox.add(male);
        cBox.add(female);
        cBox.add(isMarried);

        Box dBox = Box.createVerticalBox();
        dBox.add(textArea);
        dBox.add(cBox);

        Box eBox = Box.createHorizontalBox();
        eBox.add(dBox);
        color.add("红色");
        color.add("蓝色");
        color.add("绿色");
        eBox.add(color);
        frame.add(eBox);

        frame.pack();
        frame.setVisible(true);
    }


    public static void main(String[] args) {
        new BasicComponentDemo().init();

    }
}
